using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;

namespace Windy.OpenLink
{
    public static class ICollectionExtension
    {
        public static void AddRange<T>(this ICollection<T> collection, params T[] items)
        {
            collection.AddRange(items as IEnumerable<T>);
        }

        public static void AddRange<T>(this ICollection<T> collection, IEnumerable<T> items)
        {
            if (collection == null)
                throw new ArgumentNullException("collection", "collection is null.");
            if (items == null)
                throw new ArgumentNullException("items", "items is null.");

            List<T> list = collection as List<T>;
            if (list != null)
            {
                list.AddRange(items);
                return;
            }

            foreach (var fo in items)
            {
                collection.Add(fo);
            }
        }
    }
}